<?php
// +----------------------------------------------------------------------
// | JavaJY Framework
// +----------------------------------------------------------------------
// | Copyright (c) http://www.javajy.com
// +----------------------------------------------------------------------
// | Author www.javajy.com <QQ:262042083>
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Think\Controller;
Vendor('taobao.TopSdk');

class ValidatorController extends Controller {
	function code(){
		//http://120.25.75.20/javajy/index.php/Admin/Validator/code/tpl/40920062/phoneNum/13611600368
		$phoneNum = $_GET["phoneNum"];
		$tpl = $_GET["tpl"]; //40920062
		$icode = rand(1000, 9999);
		$vcode = "'" . $icode . "'";

		$c = new \TopClient;
		$c->appkey = "23598373" ;
		$c->secretKey = "12befff76d09a883f60c3bdc02432fc3" ;

		$req = new \AlibabaAliqinFcSmsNumSendRequest;
		$req->setExtend( "" );
		$req->setSmsType( "normal" );
		$req->setSmsFreeSignName( "记账宝" );
		$req->setSmsParam( "{vcode:$vcode}" );
		$req->setRecNum( $phoneNum );
		$req->setSmsTemplateCode( "SMS_$tpl" );
		$resp = $c->execute( $req );
		
		$this->returnJson('200','success',$vcode);
	}
	
	public function returnJson($type=null, $message=null, $data=null) {
		$response = array();
		$response['type'] = $type;
		$response['data'] = $data;
		$response['message'] = $message;
		$this->ajaxReturn($response, 'jsonp');
	}
}